import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "课程",
    component: Home
  },
  {
    path: "/login",
    name: "登录",
    component: () => import("../views/Login.vue")
  },
  {
    path: "/course",
    name: "课程详情",
    component: () => import("../views/Course.vue")
  },
  {
    path: "/teach",
    name: "课程教学",
    component: () => import("../views/Teach.vue"),
    children: [
      {
        path: "home",
        name: "教师课程主页",
        component: () => import("../views/TeachHomepage.vue")
      },
      {
        path: "files",
        name: "课件管理",
        component: () => import("../views/TeachFile.vue")
      },
      {
        path: "online",
        name: "直播教学",
        component: () => import("../views/TeachOnline.vue")
      },
      {
        path: "discussion",
        name: "问答讨论",
        component: () => import("../views/Discussion.vue")
      }
    ]
  },
  {
    path: "/study",
    name: "课程学习",
    component: () => import("../views/Study.vue"),
    children: [
      {
        path: "home",
        name: "课程主页",
        component: () => import("../views/CourseHomepage.vue")
      },
      {
        path: "files",
        name: "课件学习",
        component: () => import("../views/CourseFile.vue")
      },
      {
        path: "online",
        name: "课程直播",
        component: () => import("../views/CourseOnline.vue")
      },
      {
        path: "discussion",
        name: "课程讨论",
        component: () => import("../views/Discussion.vue")
      }
    ]
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue")
  }
];

const router = new VueRouter({
  routes
});

export default router;
